﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualTournaments.Business.Tournaments;

namespace VirtualTournaments.Business.Bets
{
    /// <summary>
    /// Representa al resultado de un partido, Local, Empate o Visitante
    /// </summary>
    public class ThreeWaysBetTarget : BetTarget
    {
        public Match Match { get; protected set; }
        public MatchWinningTeam ExpectedResult { get; set; }

        public ThreeWaysBetTarget(Match match,MatchWinningTeam resultPrediction)
        {
            this.ExpectedResult = resultPrediction;
            this.Match = match;
        }

        public override bool Occurs()
        {
            MatchWinningTeam result;
            if (Match.Result.GetWinner() == Match.Local)
            {
                result = MatchWinningTeam.Local;
            }
            else if (Match.Result.GetWinner() == Match.Visitor)
            {
                result = MatchWinningTeam.Visitor;
            }
            else
            {
                result = MatchWinningTeam.Draw;
            }
            return result.CompareTo(this.ExpectedResult) == 0;
        }
    }
}
